package com.love.travel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.love.common.log.annotation.Log;
import com.love.common.log.enums.BusinessType;
import com.love.common.security.annotation.RequiresPermissions;
import com.love.travel.domain.TravelAttractionTag;
import com.love.travel.service.ITravelAttractionTagService;
import com.love.common.core.web.controller.BaseController;
import com.love.common.core.web.domain.AjaxResult;
import com.love.common.core.utils.poi.ExcelUtil;
import com.love.common.core.web.page.TableDataInfo;

/**
 * 景点-标签关联Controller
 * 
 * @author love
 * @date 2025-10-20
 */
@RestController
@RequestMapping("/attractionTag")
public class TravelAttractionTagController extends BaseController
{
    @Autowired
    private ITravelAttractionTagService travelAttractionTagService;

    /**
     * 查询景点-标签关联列表
     */
    @RequiresPermissions("travel:tag:list")
    @GetMapping("/list")
    public TableDataInfo list(TravelAttractionTag travelAttractionTag)
    {
        startPage();
        List<TravelAttractionTag> list = travelAttractionTagService.selectTravelAttractionTagList(travelAttractionTag);
        return getDataTable(list);
    }

    /**
     * 导出景点-标签关联列表
     */
    @RequiresPermissions("travel:tag:export")
    @Log(title = "景点-标签关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelAttractionTag travelAttractionTag)
    {
        List<TravelAttractionTag> list = travelAttractionTagService.selectTravelAttractionTagList(travelAttractionTag);
        ExcelUtil<TravelAttractionTag> util = new ExcelUtil<TravelAttractionTag>(TravelAttractionTag.class);
        util.exportExcel(response, list, "景点-标签关联数据");
    }

    /**
     * 获取景点-标签关联详细信息
     */
    @RequiresPermissions("travel:tag:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(travelAttractionTagService.selectTravelAttractionTagById(id));
    }

    /**
     * 新增景点-标签关联
     */
    @RequiresPermissions("travel:tag:add")
    @Log(title = "景点-标签关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelAttractionTag travelAttractionTag)
    {
        return toAjax(travelAttractionTagService.insertTravelAttractionTag(travelAttractionTag));
    }

    /**
     * 修改景点-标签关联
     */
    @RequiresPermissions("travel:tag:edit")
    @Log(title = "景点-标签关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelAttractionTag travelAttractionTag)
    {
        return toAjax(travelAttractionTagService.updateTravelAttractionTag(travelAttractionTag));
    }

    /**
     * 删除景点-标签关联
     */
    @RequiresPermissions("travel:tag:remove")
    @Log(title = "景点-标签关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(travelAttractionTagService.deleteTravelAttractionTagByIds(ids));
    }
}
